package com.example.liuke.guangguang.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import com.example.liuke.guangguang.untils.openapp;

/**
 * Created by liuke on 2018/5/9.
 */

public class Receiver extends BroadcastReceiver {
    static final String action_boot="android.intent.action.BOOT_COMPLETED";
    static final String action_user= "android.intent.action.USER_PRESENT";
    @Override
    public void onReceive(Context context, Intent intent){
        //onReceive方法的内容就是接收了广播之后的处理方法。

       /* if (intent.getAction().equals(action_boot) || intent.getAction().equals(action_user))
        {
            Toast.makeText(context,"开机广播",Toast.LENGTH_SHORT).show();
            //这是对某个activity的自启动
            //Intent StartIntent=new Intent(context,MainActivity.class);
            //Intent StartIntent=new Intent(context,Videotwo.class);
            // context.startService(new Intent(context,myservice.class));
            //这是对整个应用的自启动
            //Intent StartIntent = context.getPackageManager().getLaunchIntentForPackage("com.example.liuke.androidggplayer");
           // StartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            //context.startActivity(StartIntent);
        }else if(intent.getAction().equals("")){

        }*/
        openapp.startActivityForPackage(context,"com.example.liuke.androidggplayer");
        Toast.makeText(context,"开机和随时广播",Toast.LENGTH_SHORT).show();
        Log.d("msg","onReceiver");
    }
}
